<?php
use Elite\Infrastructure\Server\Listener\Listener;
use Elite\Infrastructure\Server\Task\Tasker;

class OnTaskListener extends Listener {

    public function event() : string {
        return 'task';
    }

    public function callback() {
        $server = func_get_arg(0);
        /** @var \Swoole\Server\Task $task */
        $task = func_get_arg(1);

        if ($task->data instanceof Tasker) {
            $task->data->setTaskId($task->id);
            (new WebBootstrap())->startTask($this->swoole, $task->data, $task);
        }

    }

}